home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / unexsol2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-25  |  1.6 KB  |  57 lines

  1. /* Unexec function for Solaris 2.x
  2.    Copyright (C) 1994 Sun Microsystems, Inc.
  3.  
  4. This file is part of XEmacs.
  5.  
  6. XEmacs is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2, or (at your option) any
  9. later version.
  10.  
  11. XEmacs is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with XEmacs; see the file COPYING.  If not, write to the Free
  18. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* #pragma ident "@(#) $Id: unexsol2.c,v 1.2 1995/01/25 20:39:16 georgn Exp $" */
  21.  
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24. #include <dlfcn.h>
  25.  
  26. #define DYNODUMP_SO    "../dynodump/dynodump.so"
  27. #define DYNODUMP_SYM    "dynodump"
  28.  
  29.  
  30. int unexec (char *new_name, char *old_name, unsigned int data_start,
  31.         unsigned int bss_start, unsigned int entry_address);
  32. int
  33. unexec (char *new_name, char *old_name, unsigned int data_start,
  34.     unsigned int bss_start, unsigned int entry_address)
  35. {
  36.   void *handle;
  37.   void (*func)(const char *file);
  38.  
  39.   if ((handle = dlopen (DYNODUMP_SO, RTLD_LAZY)) == NULL)
  40.     {
  41.       fprintf (stderr, "Can't open %s\n", (char *) DYNODUMP_SO);
  42.       exit (1);
  43.     }
  44.  
  45.   if ((func = (void (*)(const char *)) dlsym (handle, DYNODUMP_SYM)) == NULL)
  46.     {
  47.       fprintf (stderr, "Can't find %s symbol\n", (char *) DYNODUMP_SYM);
  48.       exit (1);
  49.     }
  50.  
  51.   (*func)(new_name);
  52.  
  53.   dlclose (handle);
  54.  
  55.   return 0;
  56. }
  57.